<%@ page language="java" import="java.util.*" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
 <%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.form.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/json2.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/messages_zh.js"></script>
	<script>
	$(function() {		 
		$("#but1").button();
        $("#but2").button();
        $("#but3").button();        
        $( "#dialog-confirm" ).dialog({
            autoOpen: false,            
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
				         var mobmc = $("#mobmc");
					     if(mobmc.val() == '') {
					      alert("需要输入模板名称");
						  return false;
						 } 
						 else{
						     $("#form1").ajaxSubmit({
					              url:"<s:url value="/jydz"/>/saveDzHttk",
					              type:'post',
					              success:function(data){
						              var ret = eval('(' + data + ')');
						              alert(ret.msg);
						              if(ret.success==true)
						              {
						                 window.location.href="<s:url value="/jydz"/>/findTiaok";
						              }
					              }		              
					         }); 
				         }
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});
		
		//为提交按钮绑定事件
	    $("#but1").click(function () {
             $("#dialog-confirm").dialog("open");
          });
     });
	
	
	//改变条款模板
	function changeHttk(value){ 
       var url =  "changeHttk?mobbm=" + value;   
       $.post(url,function(data){
	       var json = eval('(' + data + ')');
	       $("#tab1").children().remove();
		   var dtable = document.getElementById("tab1");
	       for(var i=0; i<json.length; i++){
		       var obj=json[i];
		       var elTr = dtable.insertRow( -1 );
		       var idTd = elTr.insertCell( -1 );
		       var sx ="<span id=\"sx"+i+"\" >"+obj.biaot+"</span><input type=\"hidden\" name=\"biaots\" value=\""+obj.biaot+"\"/>"
		       idTd.innerHTML = sx;
		       var jfTd = elTr.insertCell(-1);
		       var jfyq="<textarea cols=\"110\" rows=\"3\" class=\"textarea\" name=\"neirs\">"+obj.neir+"</textarea>";     
		       jfTd.innerHTML=jfyq;
	       }
       });
    }
	</script>
  </head>
  <body>
<div id="best1">
<form name="form1" id="form1">
<table id="list_search" cellpadding="0" cellspacing="0" border="0" class="content_gridview">
       <tr><td>
       
       <table cellpadding="0" cellspacing="0" border="0" class="content_gridview">
       <tr>
        	<td>
            	<FONT  COLOR="#FF0000">*</FONT>模板名称:
            </td>
            <td>
            	<input type="text" id="mobmc" name="mobmc" class="longtextbox" /> 
            </td>
            <td> 
                                                加载已定制模板: 
            </td>
            <td>
            	<div class="select">
							<div>
								<select name="tkmc" style="width:180px" onchange="changeHttk(this.value)">
									<option value="-1" selected>默认</option>
									<c:forEach var="mob" items="${moblist}">
										<option value="${mob.id}">${mob.name}</option>
									</c:forEach>
								</select>
							</div>
				 </div>
            </td>            
            
        </tr>
       </table>
       
       </td></tr>
       
		<tr>
        	<td>
      	        <table id="tab1" cellpadding="0" cellspacing="0" border="0" class="content_gridview">
					<c:forEach var="tiaok" items="${httiaok}">
						<tr>
							<td ><span >${tiaok.xh}${tiaok.biaot}</span>
							<input type="hidden" name="biaots" value="${tiaok.biaot}"/>
							</td>
							<td><textarea cols="110" rows="3" class="textarea" name="neirs">${tiaok.neir}</textarea>
							</td>
						</tr>
					</c:forEach>
				</table>
        	</td>
        </tr>
       
        <tr>
		    <td colspan="4" align="center">		    
			    <input id="but1" type="button" value="确认"/>	&nbsp;&nbsp;&nbsp;
			    <input id="but2" type="reset"  value="重置" />&nbsp;&nbsp;&nbsp;
			    <input id="but3" type="button" name="" value="返回" onclick="javascript:history.back();"/>
		    </td>
        </tr>
  </table> 
</form>
</div> 

<div id="dialog-confirm" title="是否确认提交？"></div>
  </body>
</html>
